package cn.taskservice.redis.limit.config;

import cn.taskservice.redis.idempotent.config.ScriptLoader;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.data.redis.core.script.DefaultRedisScript;

@Configuration
public class LimitScriptConfig {

    private static final String LIMIT_LUA_PATH = "script/limit.lua";

    /**
     * 限流脚本注册为 Spring Bean，可通过 @Qualifier("limitScript") 注入
     */
    @Bean("limitScript")
    public DefaultRedisScript<Long> limitScript(ScriptLoader scriptLoader) {
        return scriptLoader.loadScript(LIMIT_LUA_PATH);
    }
}